package com.guigu.wenzhiyi.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.tankai.mapper.MemberMapper;
import com.guigu.tankai.pojo.Member;
import com.guigu.wenzhiyi.mapper.BodytypeMapper;
import com.guigu.wenzhiyi.pojo.Bodytype;
import com.guigu.wenzhiyi.service.BodytypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BodytypeServiceImpl  implements BodytypeService {

    @Autowired
    BodytypeMapper bodytypeMapper;

    @Autowired
    MemberMapper memberMapper;

    @Override
    public PageInfo<Bodytype> page(Integer num, Integer size, String name) {
        PageHelper.startPage(num,size);
        List<Bodytype> list =bodytypeMapper.page(name);
        PageInfo<Bodytype> p = new PageInfo<>(list);
        return  p;
    }

    @Override
    public List<Member> memberList(Member member) {
        return memberMapper.Memberlist(member);
    }

    @Override
    public int add(Bodytype bodytype) {
        int insert = bodytypeMapper.insert(bodytype);
        return bodytype.getId();
    }

    @Override
    public int update(Bodytype bodytype) {
        return bodytypeMapper.updateByPrimaryKeySelective(bodytype);
    }

    @Override
    public int delete(Integer id) {
        return bodytypeMapper.deleteByPrimaryKey(id);
    }
}
